package pe.com.slcsccy.aegis.model.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;

import pe.com.slcsccy.aegis.model.beans.Servicio;
import pe.com.slcsccy.aegis.model.beans.ServicioExample;


@Repository("servicioDAO")
public class ServicioDAOImpl extends SqlMapClientDaoSupport implements ServicioDAO {

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public ServicioDAOImpl() {
        super();
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int countByExample(ServicioExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("servicio.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int deleteByExample(ServicioExample example) {
        int rows = getSqlMapClientTemplate().delete("servicio.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int deleteByPrimaryKey(Long idServicio) {
        Servicio key = new Servicio();
        key.setIdServicio(idServicio);
        int rows = getSqlMapClientTemplate().delete("servicio.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public void insert(Servicio record) {
        getSqlMapClientTemplate().insert("servicio.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public void insertSelective(Servicio record) {
        getSqlMapClientTemplate().insert("servicio.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    @SuppressWarnings("unchecked")
    public List<Servicio> selectByExampleWithBLOBs(ServicioExample example) {
        List<Servicio> list = getSqlMapClientTemplate().queryForList("servicio.ibatorgenerated_selectByExampleWithBLOBs", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    @SuppressWarnings("unchecked")
    public List<Servicio> selectByExampleWithoutBLOBs(ServicioExample example) {
        List<Servicio> list = getSqlMapClientTemplate().queryForList("servicio.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public Servicio selectByPrimaryKey(Long idServicio) {
        Servicio key = new Servicio();
        key.setIdServicio(idServicio);
        Servicio record = (Servicio) getSqlMapClientTemplate().queryForObject("servicio.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int updateByExampleSelective(Servicio record, ServicioExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("servicio.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int updateByExampleWithBLOBs(Servicio record, ServicioExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("servicio.ibatorgenerated_updateByExampleWithBLOBs", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int updateByExampleWithoutBLOBs(Servicio record, ServicioExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("servicio.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int updateByPrimaryKeySelective(Servicio record) {
        int rows = getSqlMapClientTemplate().update("servicio.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int updateByPrimaryKeyWithBLOBs(Servicio record) {
        int rows = getSqlMapClientTemplate().update("servicio.ibatorgenerated_updateByPrimaryKeyWithBLOBs", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    public int updateByPrimaryKeyWithoutBLOBs(Servicio record) {
        int rows = getSqlMapClientTemplate().update("servicio.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table servicio
     *
     * @ibatorgenerated Wed Jun 20 09:16:22 COT 2012
     */
    private static class UpdateByExampleParms extends ServicioExample {
        private Object record;

        public UpdateByExampleParms(Object record, ServicioExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }

    @Override
    public List<Servicio> selectAllServiciosActivos(Long idEmpresa) {
        Map<String,Object> parametros = new HashMap<String,Object>();
        parametros.put("idEmpresa",idEmpresa);
        List<Servicio> list = getSqlMapClientTemplate().queryForList("servicio.selectAllServiciosActivos", parametros);
        return list;
    }
    
    @Autowired
    public void createSqlMapClient(@Qualifier("sqlMapClient")  SqlMapClient sqlMapClient){
      setSqlMapClient(sqlMapClient);
    }
}